//============================================================================
// Author      : Bubuntux 	<bubuntux@gmail.com>
// Copyright   : GNU General Public License v3
// Description : Escanea usb de forma automatica
//============================================================================

#include "ui/Ui.h"
#include "ui/Header.h"
#include "ui/Footer.h"
#include "core/Terminal.h"
#include "ui/Frame.h"
#include "core/UnixCommand.h"

#define PANELCOUNT 4

int main() {

	initscr();
	getmaxyx(stdscr,Ui::totalHeight,Ui::totalWidth);

	cbreak();
	noecho();

	start_color();
	Ui::initColors();

	Header header;
	Footer footer;

	header.print();
	footer.print();

	unsigned int frameHeight = (Ui::totalHeight - header.heigt - 1) / 2;
	unsigned int frameWidth = Ui::totalWidth / 2;

	Terminal f[PANELCOUNT];
	f[0] = Terminal(frameHeight, frameWidth, header.heigt + 1, 0);
	f[1] = Terminal(frameHeight, frameWidth, header.heigt + 1, frameWidth + 1);
	f[2] = Terminal(frameHeight, frameWidth, frameHeight + header.heigt, 0);
	f[3] = Terminal(frameHeight, frameWidth, frameHeight + header.heigt,
			frameWidth + 1);

	while (1) {
		//every second or something
		for (int i = 0; i < PANELCOUNT; ++i) {
			f[i].refresh();
		}

		footer.refreshTime();
		update_panels();
		doupdate();
		getch();
	}
	endwin();
}
